package com.android.lgc.android_mvp;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.lgc.android_mvp.IPresenter.LoginPersenter;
import com.android.lgc.android_mvp.IView.LoginView;
import com.android.lgc.android_mvp.base.BaseFragment;
import com.kotiln.lgc.android_mvp.R;

/**
 * @author $
 * @fileName LoginFragment
 * @date2021/3/9 10:05
 * @describe TODO
 * @desc
 */
public class LoginFragment extends BaseFragment<LoginView, LoginPersenter> implements LoginView {


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
    public LoginPersenter createPersenter() {
        return new LoginPersenter();
    }

    @Override
    public LoginView createView() {
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_main, null);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        view.findViewById(R.id.btnLogin).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                getPersenter().login("admin", "123456");
            }
        });
    }

    @Override
    public void onLoginResult(String result) {
        Toast.makeText(getContext(), "result:" + result, Toast.LENGTH_SHORT).show();
    }

}
